package com.oa.gform.client.ui;

import java.util.ArrayList;
import java.util.List;

import com.google.gwt.user.client.Command;
import com.oa.gform.client.ui.datasource.GItemsDataSource;

/***
 * Implementazione base di una field con item
 * @author Marco
 *
 * @param <T>
 */
public class GBaseItemsFieldImpl<T> extends GBaseFieldImpl<T> {
	GItemsDataSource<T,?,?> gItemsDataSource;
	List<Command> loadDataListeners = new ArrayList<Command>();
	
	public GBaseItemsFieldImpl(GField<T> fieldImpl) {
		super(fieldImpl);
	}
	
	public void setGItemsDatasource(GItemsDataSource<T,?,?> datasource) {
		this.gItemsDataSource = datasource;
	}

	public GItemsDataSource<T,?,?> getGItemsDatasource() {
		return gItemsDataSource;
	}
	
	public void addLoadDataListener(Command onLoadData) {
		loadDataListeners.add(onLoadData);	
	}
	public void removeLoadDataListener(Command onLoadData) {
		loadDataListeners.remove(onLoadData);
	}
	
	
	public void invokeLoadDataEnd() {
		for (Command command : loadDataListeners) {
			command.execute();	
		}
	}

	

	
}
